package com.CNMedical.web.controller.system;

import java.util.List;

import com.CNMedical.system.domain.vo.AppletKnowledgeVO;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.CNMedical.common.annotation.Log;
import com.CNMedical.common.core.controller.BaseController;
import com.CNMedical.common.core.domain.AjaxResult;
import com.CNMedical.common.enums.BusinessType;
import com.CNMedical.system.domain.entity.AppletKnowledge;
import com.CNMedical.system.service.IAppletKnowledgeService;
import com.CNMedical.common.core.page.TableDataInfo;

/**
 * 知识信息Controller
 * 
 * @author tang
 * @date 2023-03-28
 */
@RestController
@RequestMapping("/system/knowledge")
public class AppletKnowledgeController extends BaseController
{
    @Autowired
    private IAppletKnowledgeService appletKnowledgeService;

    /**
     * 查询知识信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:knowledge:list')")
    @GetMapping("/list")
    public TableDataInfo list(AppletKnowledge appletKnowledge)
    {
        startPage();
        List<AppletKnowledgeVO> list = appletKnowledgeService.selectAppletKnowledgeList(appletKnowledge);
        return getDataTable(list);
    }
//
//    /**
//     * 导出知识信息列表
//     */
//    @PreAuthorize("@ss.hasPermi('system:knowledge:export')")
//    @Log(title = "知识信息", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, AppletKnowledge appletKnowledge)
//    {
//        List<AppletKnowledgeVO> list = appletKnowledgeService.selectAppletKnowledgeList(appletKnowledge);
//        ExcelUtil<AppletKnowledge> util = new ExcelUtil<AppletKnowledge>(AppletKnowledge.class);
//        util.exportExcel(response, list, "知识信息数据");
//    }

    /**
     * 获取知识信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:knowledge:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(appletKnowledgeService.selectAppletKnowledgeById(id));
    }

    /**
     * 新增知识信息
     */
    @PreAuthorize("@ss.hasPermi('system:knowledge:add')")
    @Log(title = "知识信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AppletKnowledge appletKnowledge)
    {
        return toAjax(appletKnowledgeService.insertAppletKnowledge(appletKnowledge));
    }

    /**
     * 修改知识信息
     */
    @PreAuthorize("@ss.hasPermi('system:knowledge:edit')")
    @Log(title = "知识信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AppletKnowledge appletKnowledge)
    {
        return toAjax(appletKnowledgeService.updateAppletKnowledge(appletKnowledge));
    }

    /**
     * 删除知识信息
     */
    @PreAuthorize("@ss.hasPermi('system:knowledge:remove')")
    @Log(title = "知识信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(appletKnowledgeService.deleteAppletKnowledgeByIds(ids));
    }
}
